*Code verified using Stata/SE 16.1.

//TABLE OF CONTENTS.
//0.0. Packages.
//1.0. Online Appendix.
//1.1. Some preparation.
//1.2. Descriptive Statistics.
//1.3. Regression Models.


//0.0. PACKAGES.

*We use "blindschemes" for all graphs, "covbal" for the balance statistics, and "xtabond2" for the dynamic GMM models. These packages can be downloaded via the Stata console:

ssc install blindschemes
ssc install covbal
ssc install xtabond2


//1.0. ONLINE APPENDIX.

*Load dataset. Below code should be performed in order.


//1.1. SOME PREPARATION.

*Sort data and xtset
sort agency_id year
xtset agency_id year

*Generate inflation-adjusted budget.
gen i_budget=budget*inflation

*Generate log budget.
gen lni_budget=ln(i_budget)

*Generate lag budget.
by agency_id: gen llni_budget = l.lni_budget

*Generate growth.
bys agency_id: gen bgrowth = (D.i_budget/L.i_budget)
replace bgrowth=bgrowth*100

*Generate lag growth.
by agency_id: gen lbgrowth = l.bgrowth

*Generate bootstrap identifier.
gen bs_agency_id=agency_id

*Use Hadi's ancient method to identify some outliers.
hadimvo bgrowth, gen(odd)


//1.2. DESCRIPTIVE STATISTICS.
sort agency_id year

//Table A1. Descriptive Statistics.
sum bgrowth conflict academic political private public council board creator l.lni_budget if bgrowth~=.

//Table A2. Covariate Balance (Estimation Sample).
covbal conflict academic political private public council board creator llni_budget if bgrowth~=.


//1.3. REGRESSION MODELS.

*We present the tables slightly out of order to save the GMM models for last.


//Table A5. Replications with Alternative Outcome Restrictions.

*Model 1.
xtreg bgrowth i.conflict i.academic i.political i.private i.public i.council i.board i.creator cl.lni_budget i.year if bgrowth<100 & bgrowth>-100, fe r

*Model 2.
xtreg bgrowth i.conflict i.academic i.political i.private i.public i.council i.board i.creator cl.lni_budget i.year if bgrowth<80 & bgrowth>-80, fe r

*Model 3.
xtreg bgrowth i.conflict i.academic i.political i.private i.public i.council i.board i.creator cl.lni_budget i.year if bgrowth<60 & bgrowth>-60, fe r

*Model 4.
xtreg bgrowth i.conflict i.academic i.political i.private i.public i.council i.board i.creator cl.lni_budget i.year if bgrowth<40 & bgrowth>-40, fe r

*Model 5.
xtreg bgrowth i.conflict i.academic i.political i.private i.public i.council i.board i.creator cl.lni_budget i.year if bgrowth<20 & bgrowth>-20, fe r


//Table A7. Replications with Inverse Probability of Treatment Weighting.

*For these models we use Stata's treatment effects environment. Because we only want to include agencies with actual variance on the treatment in these models, we start by creating a set of variables that identify those agencies and then use them to restrict the estimation sample. We also add a year restriction to avoid a few years in the 1970s with constant treatment status.
 
egen xmin=min(conflict), by(agency_id)
egen xmax=max(conflict), by(agency_id)

*IPTW 1.
teffects ipw (bgrowth) (conflict academic political private public creator board council llni_budget i.year i.ministry_code) if year>1976 & odd==0 & xmin==0 & xmax==1, vce(robust)

*Imai-Ratkovic test, somewhat slow.
tebalance overid

*IPTW 2.
teffects ipw (bgrowth) (conflict academic political private public creator board council llni_budget lbgrowth i.year i.ministry_code) if year>1976 & odd==0 & l.odd==0 & xmin==0 & xmax==1, vce(robust)

*Imai-Ratkovic test, somewhat slow.
tebalance overid

*FE 1.
xtreg bgrowth conflict academic political private public council board creator llni_budget i.year if year>1976 & odd==0 & xmin==0 & xmax==1, fe r

*FE 2.
xtreg bgrowth conflict academic political private public council board creator llni_budget lbgrowth i.year if year>1976 & odd==0 & l.odd==0 & xmin==0 & xmax==1, fe r


//Table A3. Article Regression Results.

*Note that we recode the outliers as missing values instead of restricting the estimation sample in the models. This is mainly to avoid some annoyances with the GMM functions in Model 3, which will otherwise incorporate information from the outlying values.
replace bgrowth=. if odd==1

*Model 1 (same as article).
bootstrap, cluster(agency_id) idcluster(bs_agency_id) group(agency_id) seed(999) reps(1000): xtreg bgrowth i.conflict i.academic i.political i.private i.public i.council i.board i.creator cl.lni_budget i.year, fe

*Model 2 (same as article).
bootstrap, cluster(agency_id) idcluster(bs_agency_id) group(agency_id) seed(999) reps(1000): mixed bgrowth i.conflict i.academic i.political i.private i.public i.council i.board i.creator cl.lni_budget i.year || agency_id: conflict, reml cov(un) iterate(100)

*Model 3 (same as article).
xtabond2 bgrowth l.bgrowth i.conflict academic political private public council board creator l.lni_budget y1974-y2014, gmmstyle(l.bgrowth conflict academic political private public council board l.lni_budget, collapse l(1 4)) ivstyle(creator y1974-y2014, eq(level)) robust twostep orthogonal

*Model 4
bootstrap, cluster(agency_id) idcluster(bs_agency_id) group(agency_id) seed(999) reps(1000): xtreg bgrowth i.conflict i.year, fe

*Model 5
bootstrap, cluster(agency_id) idcluster(bs_agency_id) group(agency_id) seed(999) reps(1000): xtreg bgrowth i.conflict i.creator i.year, fe

*Model 6
bootstrap, cluster(agency_id) idcluster(bs_agency_id) group(agency_id) seed(999) reps(1000): xtreg bgrowth i.conflict i.board i.year, fe


//Table A4. Replications with Multiple Imputation.

*Recode outliers as missing values for GMM models.
replace bgrowth=. if odd==1

*For these models we use Stata's multiple imputation environment. We begin by fitting an imputation model for the sector covariates.

set seed 999
mi set flong
mi xtset agency_id year
mi register imputed academic political private public
mi impute chained (logit) academic political private public = bgrowth conflict creator board council llni_budget, add(20) force

*Model 1.
mi estimate, dots: xtreg bgrowth conflict academic political private public creator board council llni_budget i.year, fe r

*Model 2. 

*This one is somewhat sketchy as it fails to compute the standard errors for the random components, presumably because the variance is too low.

mi estimate, dots: mixed bgrowth conflict academic political private public creator board council llni_budget i.year || agency_id: conflict, mle cov(un)

*Model 3. 

*Because we now also want to include the lagged outcome, we must first revert back to the pre-imputed dataset and then refit the imputation model.

mi extract 0, clear 

set seed 999
mi set flong
mi xtset agency_id year
mi register imputed academic political private public
mi impute chained (logit) academic political private public = bgrowth lbgrowth conflict creator board council llni_budget, add(20) force

mi estimate, dots: xtabond2 bgrowth l.bgrowth i.conflict academic political private public council board creator l.lni_budget y1974-y2014, gmmstyle(l.bgrowth conflict academic political private public council board l.lni_budget, collapse l(1 4)) ivstyle(creator y1974-y2014, eq(level)) robust twostep orthogonal

*Revert to pre-imputed dataset before moving on to the next set of models.
mi extract 0, clear


//Table A6. Replications with Lagged Instrumentation.

*Recode outliers as missing values for GMM models.
replace bgrowth=. if odd==1

*Five Lags.
xtabond2 bgrowth l.bgrowth i.conflict academic political private public creator board council l.lni_budget y1974-y2014, gmmstyle(l.bgrowth conflict academic political private public board council l.lni_budget, collapse l(1 5)) ivstyle(creator y1974-y2014, eq(level)) robust twostep orthogonal

*Four Lags.
xtabond2 bgrowth l.bgrowth i.conflict academic political private public creator board council l.lni_budget y1974-y2014, gmmstyle(l.bgrowth conflict academic political private public board council l.lni_budget, collapse l(1 4)) ivstyle(creator y1974-y2014, eq(level)) robust twostep orthogonal

*Three Lags.
xtabond2 bgrowth l.bgrowth i.conflict academic political private public creator board council l.lni_budget y1974-y2014, gmmstyle(l.bgrowth conflict academic political private public board council l.lni_budget, collapse l(1 3)) ivstyle(creator y1974-y2014, eq(level)) robust twostep orthogonal

*Two Lags.
xtabond2 bgrowth l.bgrowth i.conflict academic political private public creator board council l.lni_budget y1974-y2014, gmmstyle(l.bgrowth conflict academic political private public board council l.lni_budget, collapse l(1 2)) ivstyle(creator y1974-y2014, eq(level)) robust twostep orthogonal

*One Lag.
xtabond2 bgrowth l.bgrowth i.conflict academic political private public creator board council l.lni_budget y1974-y2014, gmmstyle(l.bgrowth conflict academic political private public board council l.lni_budget, collapse l(1 1)) ivstyle(creator y1974-y2014, eq(level)) robust twostep orthogonal

*No Lags.
xtreg bgrowth l.bgrowth i.conflict academic political private public creator board council l.lni_budget y1974-y2014, fe r




